using System;
using System.Collections.Generic;
using System.Text;
using QiHe.CodeLib;

namespace QiHe.CodeGen
{
    public class Struct : ClassMember
    {
        public Namespace Namespace;

        public List<ClassMember> Members;

        public Struct(string name)
        {
            Name = CSharp.Identifier(name);
            Members = new List<ClassMember>();

            Modifiers = new List<string>();
        }


        public override ICodeBlock CodeBlock
        {
            get
            {
                string modifier = StringHelper.ContactWithDelim(Modifiers, " ", null);

                CodeBlock block = new CodeBlock();
                block.Leading = modifier + " struct " + Name;
                foreach (ClassMember member in Members)
                {
                    block.Add(member.Header);
                    block.Add(member.CodeBlock);
                    block.AddBlankLine();
                }
                return block;
            }
        }
    }
}
